/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//登陆是否成功状态
var isOk = false;

//用来提示账号密码不能为空
function isEmpty() {
    //获取账号,密码输入框对象
    var idTip = document.getElementById("idTip");
    var passwordTip = document.getElementById("passwordTip");
    var codeTip = document.getElementById("codeTip");
    passwordTip.innerHTML = "";
    idTip.innerHTML = "";
     codeTip.innerHTML = "";
    //当密码或者账号为空时
    if (document.lgform.username.value.length < 1 || document.lgform.password.value.length < 1 || document.lgform.code.value.length < 1) {
        if (document.lgform.username.value.length < 1) {
            idTip.innerHTML = "账号不能为空";
        } else {
            idTip.innerHTML = "";
        }

        if (document.lgform.password.value.length < 1) {
            passwordTip.innerHTML = "密码不能为空";
        } else {
            passwordTip.innerHTML = "";
        }
        if (document.lgform.code.value.length < 1) {
            codeTip.innerHTML = "验证码不能为空";
        } else {
            codeTip.innerHTML = "";
        }
        //return false;
    }
    ajaxLogin();
    return false;
}

function myReload() {
    document.getElementById("CreateCheckCode").src =
            document.getElementById("CreateCheckCode").src + "?nocache=" + new Date().getTime();
}

//ajax异步请求进行登陆验证
function ajaxLogin() {
    $.post("/ssms/securityLogin",$("#loginForm").serialize(),function (data) {
        console.log(data);
        if(data.code==0)window.location.href="/ssms/index.jsp";
    },"json");
}
